/**
 * -----------------------------------
 * Copyright (c) 2021-2023
 * All rights reserved, Designed By www.linfeng.tech
 * 林风社交论坛商业版本请务必保留此注释头信息
 * 商业版授权联系技术客服	 QQ:  3582996245
 * 严禁分享、盗用、转卖源码或非法牟利！
 * 版权所有 ，侵权必究！
 * -----------------------------------
 */
package io.linfeng.modules.app.controller;

import io.linfeng.common.utils.AppPageUtils;
import io.linfeng.common.utils.R;
import io.linfeng.common.utils.Result;
import io.linfeng.modules.admin.entity.AppUserEntity;
import io.linfeng.modules.admin.service.LuckdrawService;
import io.linfeng.modules.app.annotation.Login;
import io.linfeng.modules.app.annotation.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.Map;


/**
 * 抽奖模块
 * @author linfeng
 * @email 3582996245@qq.com
 * @date 2022-08-14 14:28:48
 */
@RestController
@RequestMapping("app/luckDraw")
@Api(tags = "移动端——抽奖模块")
public class AppLuckDrawController {

    @Autowired
    private LuckdrawService luckdrawService;

    @Login
    @GetMapping("/getPrize")
    @ApiOperation("获取奖品信息")
    public Result<Map<String,Object>> getPrize(@ApiIgnore @LoginUser AppUserEntity user){
        Map<String,Object> map=luckdrawService.getPrize(user);
        return new Result<Map<String,Object>>().ok(map);
    }

    @Login
    @GetMapping("/start")
    @ApiOperation("用户抽奖")
    public Result<Map<String,Object>> start(@ApiIgnore @LoginUser AppUserEntity user){

        Map<String,Object> map=luckdrawService.startLuckDraw(user);
        return new Result<Map<String,Object>>().ok(map);
    }

    @Login
    @GetMapping("/record/{page}")
    @ApiOperation("抽奖记录")
    public Result<AppPageUtils> record(@ApiIgnore @LoginUser AppUserEntity user,@PathVariable("page") Integer page){

        AppPageUtils pages=luckdrawService.record(user,page);
        return new Result<AppPageUtils>().ok(pages);
    }




}
